import { observable } from 'mobx';


const BaseStore = observable({
    myWin: {
        inner_w: 0,
        inner_h: 0,
        scale_x: 1,
        scale_y: 1,
        scale_rate: 1
    },

    socketData: {
        socket_success: false,
        role: '', //未知  0 受控  1 主控
        header: {},
        socket: null,
        tearch_guid: '',
        doEmit: function (key, data) {

            //是主控方才可以发
            if (this.tearch_guid == this.header.guid) {

                if (data['header']) {
                    this.socket.emit(key, data)
                } else {
                    this.socket.emit(key, {
                        header: this.header,
                        body: data
                    })
                }

            }


        }
    },

    topHeader: {
        show: false,
        backTo: '/entry',
        backShow: false,
        backHome: true,
        title: ''

    },
    appPreUrl: 'http://101.132.120.193:1005/',
    picPreUrl: "http://101.132.120.193:1004/",
    getPicInnerStaticPreUrl: window.location.protocol + '//' + window.location.host + "/pic/",


    GetFinalImageUrl(url) {
        if (url == null || url == undefined) {
            return '';
        }
        if (url.startsWith('data:image')) {
            return url;
        }
        return url.toString().indexOf('http') > -1 ? url : (this.picPreUrl + url);
    },

    GetFinalImageUrlForCanvas(url) {
        if (url == null || url == undefined) {
            return '';
        }
        if (url.startsWith('data:image')) {
            return url;
        }
        url = url.toString().indexOf('http') > -1 ? url : (this.picPreUrl + url);

        return url.replace(this.picPreUrl + "Images/", "http://" + window.location.host + "/ng_images/");

        // return url.replace(":1001/Images/",":81/ng_images/");
    }

})


export default BaseStore;